//
//  CustomScrollView.m
//  UI09_homework
//
//  Created by aaaaaa on 16/6/16.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "CustomScrollView.h"

@implementation CustomScrollView


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setProperty];
    }
    return self;
}


- (void)setProperty{
    self.pagingEnabled = YES;
    self.bounces = NO;
}

- (void)setImageArray:(NSArray<UIImage *> *)imageArray{
    if (_imageArray != imageArray) {
        [_imageArray release];
        _imageArray = [imageArray retain];
    }
    
    self.contentSize = CGSizeMake(self.frame.size.width * imageArray.count, 0);
    [self addImage:imageArray];
}

- (void)addImage:(NSArray<UIImage *> *)imageArray{
    for (int i = 0; i < imageArray.count; i++) {
        UIImageView *imageView = [[UIImageView alloc] initWithImage:imageArray[i]];
        imageView.frame = CGRectMake(CGRectGetWidth(self.bounds) * i, 0, CGRectGetWidth(self.bounds), CGRectGetHeight(self.bounds));
        [self addSubview:imageView];
        [imageView release];

    }
}





@end
